<template>
  <div
    class="gantt-block-row"
    :class="{'weekend': isWeekend}"
    :style="{
      top: rowData.rawIndex * cellHeight + 'px',
      height: `${cellHeight}px`
    }"
  >
    <template v-for="blockItem in showList">
      <slot name="blockItem" :blockData="blockItem" />
    </template>
  </div>
</template>

<script>
import dayjs from "dayjs";

export default {
  name: "blockRow",
  props: {
    rowData: {
      type: Object,
      required: true
    },
    cellHeight: Number,
    showList: Array,
    currentTime: {
      type: Object,
      default: () => dayjs()
    }
  },
  computed: {
    isWeekend() {
      // 检查当前行是否属于周末
      if (this.showList && this.showList.length > 0) {
        const firstBlock = this.showList[0];
        const date = dayjs(firstBlock.start);
        const dayOfWeek = date.day();
        // 0是周日，6是周六
        return dayOfWeek === 0 || dayOfWeek === 6;
      }
      return false;
    }
  }
};
</script>
